/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "PERSONAL_INFO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PersonalInfo.findAll", query = "SELECT p FROM PersonalInfo p"),
    @NamedQuery(name = "PersonalInfo.findByIdPersonalInfo", query = "SELECT p FROM PersonalInfo p WHERE p.personalInfoPK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "PersonalInfo.findByIdBranchenterprise", query = "SELECT p FROM PersonalInfo p WHERE p.personalInfoPK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "PersonalInfo.findByIdEnterprise", query = "SELECT p FROM PersonalInfo p WHERE p.personalInfoPK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "PersonalInfo.findByS3r4Level", query = "SELECT p FROM PersonalInfo p WHERE p.s3r4Level = :s3r4Level"),
    @NamedQuery(name = "PersonalInfo.findByUsertype", query = "SELECT p FROM PersonalInfo p WHERE p.usertype = :usertype"),
    @NamedQuery(name = "PersonalInfo.findByName", query = "SELECT p FROM PersonalInfo p WHERE p.name = :name"),
    @NamedQuery(name = "PersonalInfo.findByLastname", query = "SELECT p FROM PersonalInfo p WHERE p.lastname = :lastname"),
    @NamedQuery(name = "PersonalInfo.findByAddress", query = "SELECT p FROM PersonalInfo p WHERE p.address = :address"),
    @NamedQuery(name = "PersonalInfo.findByEmail", query = "SELECT p FROM PersonalInfo p WHERE p.email = :email"),
    @NamedQuery(name = "PersonalInfo.findByPhone", query = "SELECT p FROM PersonalInfo p WHERE p.phone = :phone"),
    @NamedQuery(name = "PersonalInfo.findByCellphone", query = "SELECT p FROM PersonalInfo p WHERE p.cellphone = :cellphone"),
    @NamedQuery(name = "PersonalInfo.findByS3r4User", query = "SELECT p FROM PersonalInfo p WHERE p.s3r4User = :s3r4User"),
    @NamedQuery(name = "PersonalInfo.findByPass", query = "SELECT p FROM PersonalInfo p WHERE p.pass = :pass")})
public class PersonalInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PersonalInfoPK personalInfoPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "S3R4_LEVEL")
    private BigInteger s3r4Level;
    @Basic(optional = false)
    @NotNull
    @Column(name = "USERTYPE")
    private Integer usertype;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "LASTNAME")
    private String lastname;
    @Size(max = 180)
    @Column(name = "ADDRESS")
    private String address;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "EMAIL")
    private String email;
    @Column(name = "PHONE")
    private BigInteger phone;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CELLPHONE")
    private BigInteger cellphone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "S3R4_USER")
    private String s3r4User;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 180)
    @Column(name = "PASS")
    private String pass;
    @Lob
    @Column(name = "PHOTO")
    private Serializable photo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private List<Record> recordList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private List<Route> routeList;
    @OneToOne(mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private Addf addf;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo1", fetch = FetchType.LAZY)
    private List<Addf> addfList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private List<Marker> markerList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private List<MemberStatus> memberStatusList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private List<S3r4Order> s3r4OrderList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private Admin admin;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personalInfo", fetch = FetchType.LAZY)
    private List<Message> messageList;
    @JoinColumn(name = "ID_LOCATION", referencedColumnName = "ID_LOCATION")
    @ManyToOne(fetch = FetchType.LAZY)
    private Location idLocation;
    @JoinColumns({
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private BranchEnterprise branchEnterprise;

    public PersonalInfo() {
    }

    public PersonalInfo(PersonalInfoPK personalInfoPK) {
        this.personalInfoPK = personalInfoPK;
    }

    public PersonalInfo(PersonalInfoPK personalInfoPK, BigInteger s3r4Level, 
            Integer usertype, String name, String lastname, String email, BigInteger cellphone, 
            String s3r4User, String pass, Location l) {
        this.personalInfoPK = personalInfoPK;
        this.s3r4Level = s3r4Level;
        this.usertype = usertype;
        this.name = name;
        this.lastname = lastname;
        this.email = email;
        this.cellphone = cellphone;
        this.s3r4User = s3r4User;
        this.pass = pass;
        this.idLocation=l;
    }

    public PersonalInfo(BigInteger idPersonalInfo, BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.personalInfoPK = new PersonalInfoPK(idPersonalInfo, idBranchenterprise, idEnterprise);
    }

    public PersonalInfoPK getPersonalInfoPK() {
        return personalInfoPK;
    }

    public void setPersonalInfoPK(PersonalInfoPK personalInfoPK) {
        this.personalInfoPK = personalInfoPK;
    }

    public BigInteger getS3r4Level() {
        return s3r4Level;
    }

    public void setS3r4Level(BigInteger s3r4Level) {
        this.s3r4Level = s3r4Level;
    }

    public Integer getUsertype() {
        return usertype;
    }

    public void setUsertype(Integer usertype) {
        this.usertype = usertype;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public BigInteger getPhone() {
        return phone;
    }

    public void setPhone(BigInteger phone) {
        this.phone = phone;
    }

    public BigInteger getCellphone() {
        return cellphone;
    }

    public void setCellphone(BigInteger cellphone) {
        this.cellphone = cellphone;
    }

    public String getS3r4User() {
        return s3r4User;
    }

    public void setS3r4User(String s3r4User) {
        this.s3r4User = s3r4User;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public Serializable getPhoto() {
        return photo;
    }

    public void setPhoto(Serializable photo) {
        this.photo = photo;
    }

    @XmlTransient
    public List<Record> getRecordList() {
        return recordList;
    }

    public void setRecordList(List<Record> recordList) {
        this.recordList = recordList;
    }

    @XmlTransient
    public List<Route> getRouteList() {
        return routeList;
    }

    public void setRouteList(List<Route> routeList) {
        this.routeList = routeList;
    }

    public Addf getAddf() {
        return addf;
    }

    public void setAddf(Addf addf) {
        this.addf = addf;
    }

    @XmlTransient
    public List<Addf> getAddfList() {
        return addfList;
    }

    public void setAddfList(List<Addf> addfList) {
        this.addfList = addfList;
    }

    @XmlTransient
    public List<Marker> getMarkerList() {
        return markerList;
    }

    public void setMarkerList(List<Marker> markerList) {
        this.markerList = markerList;
    }

    @XmlTransient
    public List<MemberStatus> getMemberStatusList() {
        return memberStatusList;
    }

    public void setMemberStatusList(List<MemberStatus> memberStatusList) {
        this.memberStatusList = memberStatusList;
    }

    @XmlTransient
    public List<S3r4Order> getS3r4OrderList() {
        return s3r4OrderList;
    }

    public void setS3r4OrderList(List<S3r4Order> s3r4OrderList) {
        this.s3r4OrderList = s3r4OrderList;
    }

    public Admin getAdmin() {
        return admin;
    }

    public void setAdmin(Admin admin) {
        this.admin = admin;
    }

    @XmlTransient
    public List<Message> getMessageList() {
        return messageList;
    }

    public void setMessageList(List<Message> messageList) {
        this.messageList = messageList;
    }

    public Location getIdLocation() {
        return idLocation;
    }

    public void setIdLocation(Location idLocation) {
        this.idLocation = idLocation;
    }

    public BranchEnterprise getBranchEnterprise() {
        return branchEnterprise;
    }

    public void setBranchEnterprise(BranchEnterprise branchEnterprise) {
        this.branchEnterprise = branchEnterprise;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personalInfoPK != null ? personalInfoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PersonalInfo)) {
            return false;
        }
        PersonalInfo other = (PersonalInfo) object;
        if ((this.personalInfoPK == null && other.personalInfoPK != null) || (this.personalInfoPK != null && !this.personalInfoPK.equals(other.personalInfoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.PersonalInfo[ personalInfoPK=" + personalInfoPK + " ]";
    }
    
}
